*********************************************************************
***                         Replication Material                  ***
***                                                               ***
*** Is It All the Same? Repression of the Media and Civil Society ***
***  Organizations as Determinants of Anti-Government Opposition  ***
***                                                               ***
*** Contact: mmgpetr@gmail.com                                    ***
*********************************************************************

*** This replication material contains:

*** 1. Code for the models in Table 1 and Table 2 and the graphs, 
*** Figure 1 and Figure 2, in the manuscript 
*** 2. Supplemental Material/Online Appendix with robustness checks & diagnostics

* Analysis run using Stata14

*******
*  1  *
*******

xtset ccode year

* Table 1

* Model 1
logit nvr_onset1  l.cso_repress l.media_repress ///
 nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

* Model 2
logit viol_onset1  l.cso_repress l.media_repress ///
violpyrs violpyrs2 violpyrs3  , cl(ccode)

* Model 3
logit nvr_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

gen nvrsample = e(sample)

* Model 4

logit viol_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)

gen violsample = e(sample) 

* Figure 1

* Re-run Model 3, Table 1
logit nvr_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)
 
margins, dydx(l.media_repress l.cso_repress) post
estimates store nvr

* Re-run Model 4, Table 1
logit viol_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)

margins, dydx(l.media_repress l.cso_repress)  post
estimates store viol

coefplot nvr viol,  xline(0)  


* Figure 2

* Re-run Model 3, Table 1
logit nvr_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

margins,  at(l.cso_repress=(0(1)4)) 
marginsplot,   recast(line) recastci(rarea) yline(0) ytitle(Pr(NVR onset)) ///
 xtitle(Repression of CSOs) title("") saving(one, replace)

margins,  at(l.media_repress=(0(1)4))
marginsplot,   recast(line) recastci(rarea) yline(0) ytitle(Pr(NVR onset)) ///
 xtitle(Repression of the media)  title("") saving(two, replace)

gr combine one.gph two.gph, col(1) iscale(1) saving(nvr, replace) ycommon

* Re-run Model 4, Table 1

logit viol_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)

margins,  at(l.cso_repress=(0(1)4)) 
marginsplot, recast(line) recastci(rarea) yline(0) ytitle(Pr(VR onset)) ///
 xtitle(Repression of CSOs) title("") saving(on, replace)

margins,  at(l.media_repress=(0(1)4)) 
marginsplot,   recast(line) recastci(rarea)  yline(0) ytitle(Pr(VR onset)) /// 
xtitle(Repression of the media)  title("") saving(tw, replace)

gr combine on.gph tw.gph, col(1) iscale(1) saving(cw, replace) ycommon

gr combine cw.gph nvr.gph, col(2) iscale(1) saving(final, replace) ycommon


* Table 2

* To run the CMP models (Roodman 2011), install: 
ssc install cmp
ssc install ghk2

cmp setup 

* Model 1
cmp (nvr_onset1 = l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure  ///
 nvrpyrs nvrpyrs2 nvrpyrs3 ) ///
 (cso_repress =  l.e_region_dem_diffuse l.i.coups_dummy i.election   l.loge_radio_n l.milexpenditure l.e_migdppcln ) ///
 (media_repress =  l.e_region_dem_diffuse l.i.coups_dummy i.election l.loge_radio_n l.milexpenditure l.e_migdppcln )  ///
 , ind(  $cmp_probit $cmp_cont $cmp_cont)  cluster(ccode)

* Model 2
cmp (viol_onset1 = l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 violpyrs violpyrs2 violpyrs3  ) ///
 (cso_repress =  l.e_region_dem_diffuse l.i.coups_dummy i.election l.loge_radio_n l.milexpenditure l.e_migdppcln ) ///
 (media_repress =  l.e_region_dem_diffuse l.i.coups_dummy i.election l.loge_radio_n l.milexpenditure  l.e_migdppcln)  ///
 , ind(  $cmp_probit $cmp_cont $cmp_cont)  cluster(ccode)


*******
*  2  *
*******

*********************************************
***                                       ***
*** SUPPLEMENTAL MATERIAL/ONLINE APPENDIX ***
***                                       ***
*********************************************


* Table A1

sum nvr_onset1 viol_onset1 cso_repress media_repress ///
 lnpop e_migdppcln e_polity2 e_polity2sqr coldwar ///
 v2stfisccap_ord  coups_dummy al_ethnic election milexpenditure  ///
 nvrpyrs violpyrs ///
 loge_radio_n e_region_dem_diffuse pts_s v2cltort_ord ///
 internet civilwar e_miurbani if nvrsample==1


* Table A1a
tab nvr_onset1 if nvrsample == 1
tab viol_onset1 if violsample==1

* Table A1b
tab cso_repress nvr_onset1 if nvrsample == 1

* Table A1c
tab media_repress nvr_onset1 if nvrsample == 1

* Table A1d
tab cso_repress viol_onset1 if violsample == 1

* Table A1e
tab media_repress viol_onset1 if violsample == 1

* Figure A1
lgraph cso_repress year if nvrsample==1, err(ci(95)) ylab(0(0.5)2.5) xlab(1961(4)2013) ///
ytitle(Average Repression of CSOs)

* Figure A2
lgraph media_repress year if nvrsample==1 , err(ci(95)) ylab(0(0.5)3) xlab(1961(4)2013) ///
ytitle(Average Repression of the media)


* Table A2 

* Model 1
logit nvr_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

* Model 2
logit nvr_onset1  l.cso_repress  ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

* Model 3
 logit nvr_onset1   l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

* Model 4
logit viol_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)

* Model 5
logit viol_onset1  l.cso_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)

* Model 6
logit viol_onset1   l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)

* Table A3

* Model 1
reg nvr_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 nvrpyrs nvrpyrs2 nvrpyrs3 i.year , cl(ccode)

* Model 2
 xtreg nvr_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 nvrpyrs nvrpyrs2 nvrpyrs3  , fe

* Model 3
 xtreg nvr_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 nvrpyrs nvrpyrs2 nvrpyrs3  i.year, fe

* Model 4
reg viol_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 i.year , cl(ccode)

* Model 5
xtreg viol_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3  , fe

* Model 6
xtreg viol_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 i.year , fe

* Table A4

* Model 1
logit nvr_onset1  l.v2csreprss l.v2mecenefm ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

* Model 2
logit viol_onset1  l.v2csreprss l.v2mecenefm ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)


* Table A5

* Model 1
reg nvr_onset1  l.v2csreprss l.v2mecenefm ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
nvrpyrs nvrpyrs2 nvrpyrs3 i.year , cl(ccode)

* Model 2
xtreg nvr_onset1  l.v2csreprss l.v2mecenefm ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
nvrpyrs nvrpyrs2 nvrpyrs3  , fe
 
* Model 3
xtreg nvr_onset1  l.v2csreprss l.v2mecenefm ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
nvrpyrs nvrpyrs2 nvrpyrs3  i.year, fe

* Model 4
reg viol_onset1 l.v2csreprss l.v2mecenefm ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 i.year , cl(ccode)

* Model 5
xtreg viol_onset1  l.v2csreprss l.v2mecenefm ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3  , fe

* Model 6
xtreg viol_onset1 l.v2csreprss l.v2mecenefm ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 i.year , fe


* Table A6

* Model 1
logit nvr_onset1  l.i.cso_repress l.i.media_repress ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

* Model 2
logit viol_onset1  l.i.cso_repress l.i.media_repress ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)

* Table A7

* Model 1
logit nvr_onset1  l.d.cso_repress l.d.media_repress  ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

* Model 2
logit viol_onset1  l.d.cso_repress l.d.media_repress ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)

* Table A8

* Model 1
logit nvr_onset1  l.cso_repress l.media_repress ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure l.pts_s ///
nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

* Model 2
logit viol_onset1  l.cso_repress l.media_repress ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure l.pts_s ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)

* Model 3
logit nvr_onset1  l.cso_repress l.media_repress ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure l.v2cltort_ord ///
nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

* Model 4
logit viol_onset1  l.cso_repress l.media_repress ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure l.v2cltort_ord ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)

* Table A9

* Model 1
logit nvr_onset1  l.cso_repress l.media_repress ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure  ///
nvrpyrs nvrpyrs2 nvrpyrs3 i.internet , cl(ccode)

* Model 2
logit viol_onset1  l.cso_repress l.media_repress ///
l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 i.internet , cl(ccode)

* Model 3
logit nvr_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure  ///
 nvrpyrs nvrpyrs2 nvrpyrs3 i.internet l.i.civilwar , cl(ccode)

* Model 4
logit viol_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 i.internet l.i.civilwar , cl(ccode)

* Model 5
logit nvr_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure  ///
 nvrpyrs nvrpyrs2 nvrpyrs3 i.internet l.i.civilwar l.e_miurbani, cl(ccode)

* Model 6
logit viol_onset1  l.cso_repress l.media_repress ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 i.internet l.i.civilwar l.e_miurbani, cl(ccode)

* Table A10

* Model 1
logit nvr_onset1  l.c.cso_repress##l.c.e_polity2 l.c.media_repress##l.c.e_polity2  ///
 l.lnpop l.e_migdppcln  l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord  l.i.coups_dummy l.al_ethnic i.election l.milexpenditure ///
 nvrpyrs nvrpyrs2 nvrpyrs3  , cl(ccode)

* Model 2
logit viol_onset1 l.c.cso_repress##l.c.e_polity2 l.c.media_repress##l.c.e_polity2 ///
 l.lnpop l.e_migdppcln l.e_polity2 l.e_polity2sqr i.coldwar ///
 l.v2stfisccap_ord l.i.coups_dummy l.al_ethnic  i.election l.milexpenditure  ///
violpyrs violpyrs2 violpyrs3 , cl(ccode)


* Collinearity diagnostics

* Table 1, Model 3
collin  cso_repress media_repress ///
lnpop e_migdppcln e_polity2 e_polity2sqr coldwar ///
v2stfisccap_ord  coups_dummy al_ethnic election milexpenditure  ///
nvrpyrs  if nvrsample==1

* Table 1, Model 4
collin  cso_repress media_repress ///
lnpop e_migdppcln e_polity2 e_polity2sqr coldwar ///
v2stfisccap_ord  coups_dummy al_ethnic election milexpenditure  ///
violpyrs if violsample == 1
